<!--头部公共部分-->
{include file="common/header" /}
<div style="padding:5px;">
    <fieldset class="layui-elem-field layui-field-title">
    </fieldset>
    <h2 style="text-align: center;margin-top: 10px;">您当前登录的组织架构在校区之上</h2>
    <div style="text-align: center;margin-top: 10px;">请选择签约校区！</div>
    <form class="layui-form" style="text-align: center;margin-top: 10px;">
        <div class="layui-input-inline">
            <select name="campus" lay-search="" lay-verify="required">
                <option value="">请选择签约校区</option>
                {volist name="campus" id="v"}
                <option value="{$v.id}">{$v['campus_name']}</option>
                {/volist}
            </select>
        </div>
        <fieldset class="layui-elem-field layui-field-title">
        </fieldset>
        <div style="text-align: center;margin-top: 10px;">
            <input class="layui-btn layui-btn-normal" lay-submit lay-filter="form" value="确定" readonly>
        </div>
    </form>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['element', 'jquery', 'form', 'laydate', 'layer'], function () {
        let $ = layui.$,
                layer = layui.layer,
                element = layui.element,
                form = layui.form;

        //监听提交
        form.on('submit(form)', function (data) {
            console.log(data);
            //发异步，把数据提交给php
            let field = data.field;
            let isLoad;
            $.ajax({
                url: '/admin/customer/close',
                method: "post",
                beforeSend: function () {

                },
                success: function (result) {
                    if (result.code === 1) {
                        $.ajax({
                            url: '{:url("Grades/campus")}',
                            method: "post",
                            data: field,
                            success: function (result) {
                                if (result.code === 1) {
                                    parent.location.href = result.url;
                                }
                            },
                            complete: function () {
                                layer.close(isLoad)
                            },
                            error: function (error) {
                                console.log(error)
                            }
                        });
                        return false;
                    }
                },
            });
        });
    });
</script>
